import 'package:appflutterhomeschool/model/papers_model.dart';
import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/ui/widgets/my_app_bar.dart';
import 'package:appflutterhomeschool/ui/widgets/notice/notice_tab_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/widgets.dart';
import 'package:appflutterhomeschool/view_model/academic_sentiment/analysis_report_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

///用户： ninetailedfox
///时间： 2020/7/5
///邮箱： 1037438704@qq.com
///功能： 考试分析报告

class AnalysisReportPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ProviderWidget<AnalysisReportViewModel>(
      model: AnalysisReportViewModel(context),
      onModelReady: (value) => value.initView(),
      builder: (context, viewModel, child) {
        return Scaffold(
          appBar: MyAppBar(
              finishBool: false,
              imageRightUrl:
                  viewModel.openScreen ? "shaixuan_true" : "shaixuan_false",
              title: "考试分析报告",
              onTapLeft: () => Navigator.pop(context),
              fontWeight: FontWeight.bold,
              onTapRight: viewModel.onTapOpenScreen),
          body: Column(
            children: <Widget>[
              NoticeTabWidget(
                rightUnread: false,
                openScreen: viewModel.openScreen,
                listTab: viewModel.listTab,
                getIndex: (index) {
                  viewModel.tapModelOnTap(index);
                },
              ),
              Expanded(
                child: ListView.builder(
                    shrinkWrap: true,
                    itemCount: viewModel.listPaperModel.length ?? 0,
                    itemBuilder: (context, index) {
                      PapersModel papersModel = viewModel.listPaperModel[index];
                      return GestureDetector(
                        onTap: () {
                          Navigator.push(
                              context,
                              MaterialPageRoute(
                                  builder: (context) => WebViewWidget(
                                        title: papersModel.name,
                                        url: papersModel.htmlUri,
                                      )));
                        },
                        child: Container(
                          color: Colors.white,
                          padding: EdgeInsets.all(ScreenUtil().setWidth(35)),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: <Widget>[
                              Container(
                                margin: EdgeInsets.only(right: 10, top: 3),
                                padding: EdgeInsets.only(
                                    top: 2, bottom: 2, left: 4, right: 4),
                                decoration: BoxDecoration(
                                    color: Colors.blue[100],
                                    borderRadius: BorderRadius.circular(3)),
                                child: Text(
                                  papersModel.subject,
                                  style: TextStyles.textBlue30,
                                ),
                              ),
                              Expanded(
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  children: <Widget>[
                                    Text(
                                      papersModel.name ?? "",
                                      style: TextStyles.textDark37,
                                    ),
                                    Text(
                                      "2020-06-15  12:30:20",
                                      style: TextStyles.textGray30,
                                    ),
                                  ],
                                ),
                              ),
                              Container(
                                alignment: Alignment.center,
                                child: Icon(
                                  Icons.arrow_forward_ios,
                                  color: Colors.grey,
                                  size: 10,
                                ),
                              )
                            ],
                          ),
                        ),
                      );
                    }),
              ),
            ],
          ),
        );
      },
    );
  }
}
